import {prisma} from "~/server/db/index.js";
import bcrypt from "bcrypt"
// 创建用户
export const createUser =(userData)=>{
    const finalUserData = {
        ...userData,
        password: bcrypt.hashSync(userData.password, 10) //哈希加密
    }
    return prisma.user.create({
        data: finalUserData
    })
}
//查询用户
export const getUserByUsername = (username)=>{
    return prisma.user.findUnique({
        where:{
            username
        }
    })
}
export const getUserById = (userId) => {
    return prisma.user.findUnique({
        where: {
            id: userId
        }
    })
}